package com.wzh.service;

import com.wzh.dao.NameListDao;
import com.wzh.pojo.Po.Card;
import com.wzh.pojo.Po.NameList;
import com.wzh.pojo.Req.DataReq;
import com.wzh.pojo.Resp.DataResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NameListService {
	@Autowired
	private NameListDao nameListDao;

	public DataResp<Object> show(DataReq req) {

		DataResp<Object> resp=new DataResp<>();
		List<NameList> list= nameListDao.findall(req);
		if (list.size()!=0){
			resp.setData(list);
			resp.setMes("查询成功！");
		}else{
			resp.setMes("查询失败！");
		}
		return  resp;
	}

	public DataResp<Object> del(NameList name) {

		DataResp<Object> resp=new DataResp<>();
		Integer code =nameListDao.del(name);
		if (code>0){
			resp.setMes("操作成功！");
		}else{
			resp.setMes("没发生任何变化！");
		}
		return  resp;
	}

	public DataResp<Object> update(NameList name) {
		DataResp<Object> resp=new DataResp<>();
		Integer code =nameListDao.update(name);
		if (code>0){
			resp.setMes("操作成功！");
		}else{
			resp.setMes("没发生任何变化！");
		}
		return  resp;
	}

	public DataResp<Object> add(NameList name) {
		DataResp<Object> resp=new DataResp<>();
		Integer code =nameListDao.add(name);
		if (code>0){
			resp.setMes("操作成功！");
		}else{
			resp.setMes("没发生任何变化！");
		}
		return  resp;
	}

}
